//
//  LOLMeViewController.m
//  LOLer
//
//  Created by kaijie on 16/3/29.
//  Copyright © 2016年 kaijie. All rights reserved.
//

#import "LOLMeViewController.h"
#import "LOLSetTableViewController.h"
#import "MeTableViewCellOfSelectArea.h"
#import "MeTableViewCellOfInformation.h"


@interface LOLMeViewController ()<UITableViewDataSource,UITableViewDelegate>{
    UIButton * buttonOfCommunityData;
    UIImageView* imageViewOfTwodimensionCode;
    UILabel * labelOfCommunityData;
    
    
}
S_property(UITableView, MeViewTableview)
@end

@implementation LOLMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _MeViewTableview.rowHeight = UITableViewAutomaticDimension;
    _MeViewTableview = UITableViewCellSeparatorStyleNone;
    _MeViewTableview.backgroundColor=[UIColor whiteColor];
    [self addUiOfView];
    [self setUiLayout];
    [self setRightBarButtonItem];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)setRightBarButtonItem{
    self.view.backgroundColor=[UIColor whiteColor];
    self.title=@"我";
    UIButton * btn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
    [btn addTarget:self action:@selector(pushInstall) forControlEvents:UIControlEventTouchDown];
    [btn setImage:[UIImage imageNamed:@"personal_setting_nor"] forState:UIControlStateNormal];
    UIBarButtonItem * item=[[UIBarButtonItem alloc]initWithCustomView:btn];
    self.navigationItem.rightBarButtonItem=item;
   
}
-(void)pushInstall{
    LOLSetTableViewController*SetView=[LOLSetTableViewController new];
    SetView.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:SetView animated:YES];
}
-(void)addUiOfView{
    [self.view addSubview:self.HeardOfView];
    [self.HeardOfView addSubview:self.imageOfHeard];
    [self.HeardOfView addSubview:self.labelOfName];
    [self.HeardOfView addSubview:self.labelOfageAndsex];
    [self.HeardOfView addSubview:[self setCommunityDataButton]];
    [buttonOfCommunityData addSubview:imageViewOfTwodimensionCode];
    [buttonOfCommunityData addSubview:labelOfCommunityData];
    [self.view addSubview:self.MeViewTableview];
}
-(void)setUiLayout{
    [_HeardOfView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.top.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(88);
    }];
    [_imageOfHeard mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_HeardOfView.mas_top).offset(12);
        make.leading.equalTo(_HeardOfView.mas_leading).offset(12);
        make.bottom.equalTo(_HeardOfView.mas_bottom).offset(-12);
        make.width.mas_equalTo(60);
    }];
    [_labelOfName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_imageOfHeard.mas_top).offset(7);
        make.top.equalTo(_imageOfHeard.mas_bottom).offset(-35);
        make.leading.equalTo(_imageOfHeard.mas_trailing).offset(14);
    }];
    [_labelOfageAndsex mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(_labelOfName);
        make.bottom.equalTo(_imageOfHeard.mas_bottom).offset(-8);
        make.height.mas_equalTo(16);
    }];
    [buttonOfCommunityData mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(_HeardOfView.mas_trailing).offset(-10);
        make.top.equalTo(_labelOfName.mas_bottom).offset(-8);
        make.width.mas_equalTo(90);
        make.height.mas_equalTo(30);
    }];
    [imageViewOfTwodimensionCode mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(buttonOfCommunityData.mas_top).offset(8);
        make.leading.equalTo(buttonOfCommunityData.mas_leading).offset(8);
        make.bottom.equalTo(buttonOfCommunityData.mas_bottom).offset(-8);
        make.width.mas_equalTo(15);
        
    }];
    [labelOfCommunityData mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(buttonOfCommunityData.mas_trailing).offset(0);
        make.leading.equalTo(imageViewOfTwodimensionCode.mas_trailing).offset(2);
        make.top.equalTo(imageViewOfTwodimensionCode.mas_top).offset(5);
        make.bottom.equalTo(imageViewOfTwodimensionCode.mas_bottom).offset(-5);
    }];
    [self.MeViewTableview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.HeardOfView.mas_bottom);
        make.leading.trailing.bottom.equalTo(self.view);
    }];
}
-(UIImageView *)HeardOfView{
    if (!_HeardOfView) {
        _HeardOfView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"personal_social_bg"]];
        
    }return _HeardOfView;
}
-(UIImageView *)imageOfHeard{
    if (!_imageOfHeard) {
        _imageOfHeard=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"4bad77ff467a352dd72d77b00bc12920.jpg"]]
        ;
        _imageOfHeard.layer.cornerRadius=4;
        _imageOfHeard.clipsToBounds=YES;
        
    }return _imageOfHeard;
}
-(UILabel *)labelOfName{
    if (!_labelOfName) {
        _labelOfName=[UILabel new];
        _labelOfName.text=@"瞬间爆炸";
        _labelOfName.textColor=[UIColor whiteColor];
  
    }return _labelOfName;
}
-(UILabel *)labelOfageAndsex{
    if (!_labelOfageAndsex) {
        _labelOfageAndsex=[UILabel new];
        _labelOfageAndsex.text=@"♂21";
        _labelOfageAndsex.textColor=[UIColor whiteColor];
        _labelOfageAndsex.layer.cornerRadius = 5;
        _labelOfageAndsex.font=[UIFont systemFontOfSize:14];
        _labelOfageAndsex.clipsToBounds=YES;
        _labelOfageAndsex.backgroundColor=[UIColor colorWithRed:57/255.f green:163/255.f blue:216/255.F alpha:1.0];
        
    }
    return _labelOfageAndsex;
}
-(UIButton*)setCommunityDataButton{
    buttonOfCommunityData=[UIButton new];
    [buttonOfCommunityData setBackgroundImage:[UIImage imageNamed:@"battle_rank_my_press"] forState:UIControlStateNormal];
    imageViewOfTwodimensionCode=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"personal_social_qr_code_icon"]];
    labelOfCommunityData=[UILabel new];
    labelOfCommunityData.text=@"社区资料 >";
    labelOfCommunityData.font = [UIFont systemFontOfSize:12];
    labelOfCommunityData.textColor = [UIColor whiteColor];
    [labelOfCommunityData addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(PushCommunity)]];
    
    
    
    return buttonOfCommunityData;
}

-(UITableView *)MeViewTableview{
    if (!_MeViewTableview) {
        _MeViewTableview=[[UITableView alloc]init];
        _MeViewTableview.delegate=self;
        _MeViewTableview.dataSource=self;
        _MeViewTableview.estimatedRowHeight = 100.f;
        _MeViewTableview.rowHeight = UITableViewAutomaticDimension;
       
       

        
    }
    return _MeViewTableview;
}
-(void)PushCommunity{
    NSLog(@"asd");
}
/*
#pragma mark - Navigation 57 163 216

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark --TableViewDeledate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 7;
    
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell*cell=[UITableViewCell new];
    if (indexPath.row==0) {
    cell=[MeTableViewCellOfSelectArea new];
    }
    if (indexPath.row==1) {
        cell=[MeTableViewCellOfInformation new];
    }
    return  cell;
}
@end
